'use strict'
import { Button, View } from '../../component'
import style from './css.css'
import { observer, inject } from 'mobx-react'
@inject('user') @observer class UserBtn extends React.Component {
  static propTypes = {
    user: PropTypes.object,
    history: PropTypes.object
  }
  _handleTap = this._handleTap.bind(this)
  _handleTap () {
    console.log(this.props.user.userInfo.uuid)
    if (!this.props.user.userInfo.uuid) {
      this.props.user.getUserInfo(true)
    }
    else {
      this.props.history.push('/set')
    }
  }
  render () {
    let styleImage = {}
    if (this.props.user.userInfo.avatar) { styleImage = { backgroundImage: `url(${this.props.user.userInfo.avatar})` } }
    return (
      <Button tapClassName={style.userHeaderPress} className={ style.userHeader } tap={this._handleTap}>
        <View style={styleImage} className={ style.userHeaderImage }></View>
      </Button>
    )
  }
}

export default UserBtn
